﻿using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using Volo.Abp.Domain.Entities.Auditing;
using Leo.Awesome.AppPlatform.Enums;
using Leo.Awesome.AppPlatform.ValueObjects;

namespace Leo.Awesome.AppPlatform.Domain;

public class Menu : FullAuditedEntity<Guid>
{
    public Menu()
    {
        Items = new List<Menu>();
    }
    public Menu(
        Guid id,
        Guid? parentId,
        string name,
        string code,
        string pathCode,
        string permission,
        MenuType menuType,
        int order,
        string routerPath,
        string routerName,
        string routerComponent,
        MenuMeta meta,
        bool display=true,
        string url = "")
    {
        Id = id;
        Name = name;
        Code = code;
        PathCode = pathCode;
        Permission = permission;
        MenuType = menuType;
        ParentId = parentId;
        Order = order;
        RouterPath = routerPath;
        RouterName = routerName;
        RouterComponent = routerComponent;
        Meta = meta;
        Url = url;
        Display = display;
        Items = new List<Menu>();
    }
    /// <summary>
    /// (菜单/目录/按钮)的名称
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 唯一标识
    /// </summary>
    public string Code { get; set; }

    /// <summary>
    /// Path路径
    /// </summary>
    public string PathCode { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    public string Permission { get; set; }

    /// <summary>
    /// 类型：目录、菜单项
    /// </summary>
    public MenuType MenuType { get; set; }

    /// <summary>
    /// 上级菜单
    /// </summary>
    public Guid? ParentId { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    public int Order { get; set; }

    /// <summary>
    ///      是否显示 默认true
    /// </summary>
    public bool Display { get; set; } = true;

    /// <summary>
    /// 打开方式:弹框、当前窗口、新窗口
    /// </summary>
    public OpenMethod? OpenMethod { get; set; }

    /// <summary>
    ///     路由地址
    /// </summary>
    public string RouterPath { get; set; }

    /// <summary>
    ///     路由名称
    /// </summary>
    public string RouterName { get; set; }

    /// <summary>
    ///     前端组件路径
    /// </summary>
    public string RouterComponent { get; set; }

    /// <summary>
    /// 菜单元
    /// </summary>
    public MenuMeta Meta { get; set; }

    /// <summary>
    /// URL地址
    /// </summary>
    public string Url { get; set; }

    public string Domain { get; set; }

    /// <summary>
    /// 子项
    /// </summary>
    public List<Menu> Items { get; }

    public virtual Menu AddChindRenItem([NotNull] Menu menuItem)
    {
        Items.Add(menuItem);
        return this;
    }
}


